/**
 * @param {number} n
 * @param {number} k
 * @return {number}
 */
 var rearrangeSticks = function(n, k) {
    const mod = Math.pow(10,9)+7
    const nums = new Array(n)
    for(let i =0 ; i<n; i++)
        nums[i] = i+1
    let ans = 0
    const dfs = (nums, pre = []) => {
        for(let i = 0; i<nums.length; i++){
            let temp = [...pre, nums[i]]
            if(nums.length == 1){
                for(let i = 1; i<k; i++){
                    if(temp[i] <= temp[i-1])
                        return 
                }
                ans += 1
            }
            else{
                let a = nums.slice()
                a.splice(i,1)
                dfs(a, temp)
            }
        }
    }
    dfs(nums)
    return ans % mod
};